home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / ICNDRW_1.ARJ / ANIMAT.PAS < prev    next >
Pascal/Delphi Source File  |  1991-08-16  |  2KB  |  87 lines

  1. {--------------------------------------------------------------------------
  2.  
  3.                       Copyright (c) 1991 SofDesign Technology
  4.                       All Rights Reserved
  5.  
  6.                       An animation program that uses icons
  7.                       as frames.  You must specify a library name
  8.                       that contains a series of icons, or frames,
  9.                       if you prefer.
  10.  
  11.  --------------------------------------------------------------------------}
  12. {$X+}
  13. {$G+}
  14. {$R-}
  15. {$S-}
  16. Program icon_animator;
  17.  
  18. uses crt,icontool,libtools,bgidriv,graph;
  19. const
  20.   maxframes = 100;
  21. var
  22.   movie : array[1..maxframes] of icon;
  23.   num : word;
  24.   frames : array[1..maxframes] of string[12];
  25.  
  26. {$I grafinit.pas}
  27.  
  28. procedure main;
  29. var i:integer;
  30.     f:file;
  31.     h:header_type;
  32.     ir : icon_record;
  33.     p:pointer;
  34.     k:char;
  35.     newx,newy :integer;
  36. begin
  37.   num:=getnumicons(paramstr(1));
  38.   if num>0 then
  39.   begin
  40.     assign(f,paramstr(1));
  41.     reset(f,1);
  42.     readheader(f,h);
  43.     for i:=1 to num do
  44.     begin
  45.       blockread(f,ir,sizeof(ir));
  46.       frames[i]:=ir.fname;
  47.       getmem(p,ir.size);
  48.       blockread(f,p^,ir.size);
  49.       freemem(p,ir.size);
  50.     end;
  51.     close(f);
  52.     for i:=1 to num do
  53.     begin
  54.       movie[i].init(paramstr(1),frames[i],getmaxx div 2, getmaxy div 2);
  55.       movie[i].setput(copyput);
  56.       movie[i].icontitle(false);
  57.     end;
  58.     i:=0;
  59.     k:=' ';
  60.     randomize;
  61.     while k<>#27 do
  62.     begin
  63.       inc(i);
  64.       if keypressed then
  65.         k:=readkey;
  66.       if i>num then
  67.       begin
  68.         newx:=random(getmaxx - 50)+1;
  69.         newy:=random(getmaxy - 50)+1;
  70.         for i:=1 to num do
  71.           movie[i].setxy(newx,newy);
  72.         cleardevice;
  73.         i:=1;
  74.       end;
  75.       movie[i].display_icon;
  76.       delay(50);
  77.     end;
  78.   end;
  79.   closegraph;
  80. end;
  81.  
  82.  
  83. begin
  84.   grafinit;
  85.   main;
  86. end.
  87.